package cn.itsource.org.mapper;

import cn.itsource.basic.basicmapper.BasicMapper;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.dto.LoginDto;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

public interface EmployeeMapper extends BasicMapper<Employee> {

    //基础的crud全部由继承得到
    List<Employee> findManagers();

    /*
    写法1
    default Employee checkRepeatEmployee(Employee admin){
        //拼接查询条件的
        Example example = new Example(Employee.class);
        example.or().orEqualTo("username",admin.getUsername());
        example.or().orEqualTo("email",admin.getEmail());
        example.or().orEqualTo("phone",admin.getPhone());

        return this.selectOneByExample(example);
    }*/

    //写法2
    @Select("select * from t_employee where username=#{username} or email = #{email} or phone = #{phone}")
    Employee checkRepeatEmployee(Employee admin);

    @Select("select * from t_employee where shop_id = #{shopId}")
    List<Employee> getShopEmployees(Long shopId);

    //写法3  xml里面写
}
